package com.lagou.web.filter;

import com.lagou.web.util.ThreadLocalUtil;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.rpc.*;

/**
 * @AUTHOR: yb.feng
 * @DATE: 2020/6/15 22:14
 * @DESC:
 */
@Activate(group = {CommonConstants.CONSUMER})
public class TransportIPFilter implements Filter {

    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        System.out.println("@@@@" + ThreadLocalUtil.getIp());
        RpcContext.getContext().setAttachment("ip", ThreadLocalUtil.getIp());
        return invoker.invoke(invocation);
    }
}
